import React, { useContext } from 'react';
import MyContext from './MyContext';
import ChildrenView from './ChildrenView';
const UseContextAndUseReducer = () => {
  const { state, dispatch } = useContext(MyContext)
  console.log(state)
  return (
    <div>
      <h1>UseContextAndUseReducer 组件</h1>
      <h3>count: {state.count}</h3>
      <h3>age: {state.age}</h3>
      <div>
        <button type='button' onClick={() => {
          dispatch({ type: 'increment' })
        }}>increment</button>
      </div>

      <ChildrenView />
    </div>
  );
}

export default UseContextAndUseReducer;
